package com.itheima03.sql;

import org.apache.ibatis.jdbc.SQL;

public class SqlTest {
    public static void main(String[] args) {
        String sql = getALL();
        System.out.println(sql);
        System.out.println("--------------");
        String insert = getInsert();
        System.out.println(insert);
        System.out.println("--------------");
        String update = getUpdate();
        System.out.println(update);
        System.out.println("--------------");
    }
    public static String getALL(){
        return new SQL(){
            {
                SELECT("*");
                FROM("student");
            }
        }.toString();
    }

    public static String getInsert(){
        return new SQL(){
            {
                INSERT_INTO("student");
                INTO_VALUES("#{id},#{name},#{age}");
            }
        }.toString();
    }

    public static String getUpdate(){
        return new SQL(){
            {
                UPDATE("student");
                SET("name=#{name}");
                SET("age=#{age}");
                WHERE("id=#{id}");
            }
        }.toString();
    }
}
